from rest_framework import serializers

from apps.home.models import Medals, Medaltypes, Usermedal, Proresult


class MedaltypesSerializers(serializers.ModelSerializer):
    class Meta:
        model = Medaltypes
        fields = ('medaltype_id', 'medaltypename')


class MedalsSerializers(serializers.ModelSerializer):
    medaltype = MedaltypesSerializers()

    class Meta:
        model = Medals
        fields = ('medal_id', 'medaltype', 'medalname')


# 根据用户id，查询对应徽章以及徽章类型
class UsermedalSerializers(serializers.ModelSerializer):
    medal = MedalsSerializers()

    class Meta:
        model = Usermedal
        fields = ('medal', 'user')


class ProresultSerializers(serializers.ModelSerializer):
    class Meta:
        model = Proresult
        fields = ('countScore', 'resultstrength', 'questiontype')
